'use strict';



let btnSave = function () {
    let id = $('[name=id]').val();
    let studentName = $('[name=studentName]').val();
    let birth = $('[name=birth]').val();
    let gender = $('[name=gender]:checked').val();

    
    let obj = {
        id, studentName, birth, gender
    }
    if (id == null || id == "" || studentName == null || studentName == "" || birth == null || birth == "" || gender == null || gender == "") {
        alert('空值请重新输入');
    }
    else{
        $.ajax({
            url: `/student/save/${id}`,
            type: `put`,
            data: obj,
            success: (res) => {
                console.log(res);
                location.href = `/student`;
            },
            error: (err) => {
                console.log(err);
            }
        });
    }
}





let btnCancel = function () {
    console.log(222);
    location.href = '/student';
}

$('[value=保存]').click(btnSave);
$('[value=取消]').click(btnCancel);